<?php

print('

<html>
<head>
<script type="text/javascript">

var menus=new Array();
menus[0]="menu0";
menus[1]="menu1";
menus[2]="menu2";
menus[3]="menu3";
menus[4]="menu4";
menus[5]="menu5";
menus[6]="menu6";

function setmenu(docid){
	if(document.getElementById(docid).style.display=="block"){
		document.getElementById(docid+"-img").src="Pictures/+.gif";
		document.getElementById(docid).style.display="none";
	}
	else{
		document.getElementById(docid+"-img").src="Pictures/-.gif";
		document.getElementById(docid).style.display="block";	
	}
} 
</script>
</head>
<body>
	
	<div id="menu">
			
');

        $con = mysql_connect("localhost","root","555");
        if (!$con){
	    	die('Could not connect: ' . mysql_error());
        }
        mysql_select_db("mlm", $con);

//		$sql = "select number from users";
	
		getParent(0,'Нурпиисов', 0);
	
	    mysql_close($con);
//        $i = 0;
		function getParent($number, $name, $i){
			$sql = "select number, lastname from users where parentNumber = ".$number;
			$result = mysql_query($sql);
            $rows = mysql_num_rows($result);
            //print("aaa ".$rows);
            if ($rows > 0 ) {
                while($row = mysql_fetch_array($result)){
                    $i=$i+1;
                    print('<img id="menu'.$i.'-img" style="width:11px;length:11px" src="Pictures/+.gif" onclick="javascript:setmenu('."'".'menu'.$i.''."'".');" /> ');
                    print("<div id='node'>".$row['lastname']."<br>1000</div>");
                    print('<div id="menu'.$i.'" style="display:none">');
                    print('<ul>');
                    getParent($row['number'],$row['lastname'],$i);
                    print('</ul>');
                    print('</div>');
                }
            }
            /*else {
                    $i=$i+1;
//                    print('<img id="menu'.$i.'-img" style="width:11px;length:11px" src="Pictures/+.gif" onclick="javascript:setmenu('."'".'menu'.$i.''."'".');" /> ');
                    print("<div id='node'> child 0: ".$name."<br>1000</div>");
//                    print('<div id="menu'.$i.'" style="display:none">');
//                    print('<ul>');
////                    getParent($row['number'],$name,$i);
//                    print('</ul>');
//                    print('</div>');
            }*/
		}

print('        
</body>
</html>

        
');
?>